package com.ps.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

@Data
public class Result {

    private long code;
    private String msg;
    private long count;
    private Object data;


    public static Result success(Object data){
        Result result=new Result();
        result.setCode(0);
        result.setData(data);
        return result;
    }
    public static Result success(String msg){
        Result result=new Result();
        result.setCode(1);
        result.setMsg(msg);
        return result;
    }
    public static Result fail(String msg){
        Result result=new Result();
        result.setCode(-1);
        result.setMsg(msg);
        return result;
    }

    public static Result success(Page page){
        Result result=new Result();
        result.setCode(0);
        result.setData(page.getRecords());
        result.setCount(page.getTotal());
        return  result;
    }




}
